<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Gestione Messaggi" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="message" />
	</ui:define>

	<ui:define name="content">
		<h:form enctype="multipart/form-data">

			<p:messages id="messages" />
			<center>
				<p:panel header="Gestione Message">
					<h:panelGrid columns="2" style="width: 95%">
						<h:outputLabel for="name" value="Nome" />
						<h:inputText id="name" value="#{messageController.element.name}"
							style="width: 100%;" required="true" />

						<h:outputLabel for="email" style="font-weight: bolder;"
							value="Email: " />
						<h:inputText id="email" value="#{messageController.element.email}"
							width="640px" />

						<h:outputLabel value="pubblica?" for="active" />
						<h:selectBooleanCheckbox title="active" id="active"
							value="#{messageController.element.active}">
						</h:selectBooleanCheckbox>

						<h:outputLabel for="dataInsert" value="Data inserimento:" />
						<p:calendar id="dataInsert"
							value="#{messageController.element.date}" pattern="dd/MM/yyyy"
							timeZone="Europe/Rome" />

						<h:outputLabel for="sourceType" style="font-weight: bolder;"
							value="Source Type: " />
						<h:outputText id="sourceType"
							value="#{messageController.element.sourceType}" />

						<h:outputLabel for="sourceKey" style="font-weight: bolder;"
							value="Source Key: " />
						<h:outputText id="sourceKey"
							value="#{messageController.element.sourceKey}" />


						<h:outputLabel for="body" value="Body:" />
						<h:inputTextarea id="body" cols="20" rows="20"
							value="#{messageController.element.body}"
							style=" height : 166px; width: 100%;" />

					</h:panelGrid>
					<br />
				</p:panel>

				<h:panelGrid columns="4">

					<h:commandButton action="#{messageController.save}" value="Salva"
						immediate="false" rendered="#{not messageController.editMode}" />

					<h:commandButton action="#{messageController.update}"
						value="Salva le modifiche" immediate="false"
						rendered="#{messageController.editMode}" />

					<h:commandButton action="#{messageController.delete}"
						value="Elimina" rendered="#{messageController.editMode}"
						immediate="true"
						onclick="if (!confirm('Vuoi davvero eliminare?')) return false" />
				</h:panelGrid>
			</center>
		</h:form>

	</ui:define>
</ui:composition>